﻿<!DOCTYPE html>
<html class="no-js" lang="zxx">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="meta description">

    <title>Dream游戏商城-注册&&登录</title>

    <!--=== Favicon ===-->
    <link rel="shortcut icon" href="assets/img/favicon.ico" type="image/x-icon"/>

    <!--== Google Fonts ==-->
    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,400i,500,600,700" rel="stylesheet">

    <!--=== Bootstrap CSS ===-->
    <link href="assets/css/vendor/bootstrap.min.css" rel="stylesheet">
    <!--=== Font-Awesome CSS ===-->
    <link href="assets/css/vendor/font-awesome.css" rel="stylesheet">
    <!--=== Plugins CSS ===-->
    <link href="assets/css/plugins.css" rel="stylesheet">
    <!--=== Helper CSS ===-->
    <link href="assets/css/helper.min.css" rel="stylesheet">
    <!--=== Main Style CSS ===-->
    <link href="assets/css/style.css" rel="stylesheet">

    <!-- Modernizer JS -->
    <script src="assets/js/vendor/modernizr-2.8.3.min.js"></script>
    <script src="js/jquery-3.3.1.min.js"></script>
    <!--[if lt IE 9]>
    <script src="http://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<!--== 头部菜单开始 ==-->
<header id="header-area">
    <!-- Start PreHeader Area -->
    <div class="preheader-area">
        <div class="container">
            <div class="row">
                <div class="col-md-5 col-lg-6">
                    <div class="preheader-contact-info d-flex align-items-center justify-content-between justify-content-md-start">
                        <div class="single-contact-info">
                            <span class="contact-icon">
                                <i class="fa fa-envelope"></i>
                            </span>
                            <a href="mailto:your@example.com" class="contact-text">
                               <strong>Email:</strong> Dream@email.here
                                   </a>
                               </div>
                               <div class="single-contact-info">
                                   <span class="contact-icon">
                                       <i class="fa fa-phone"></i>
                                   </span>
                                   <a href="" class="contact-text">
                                       <strong>电话:</strong> (+86) 188-8888-8888
                            </a>
                        </div>
                    </div>
                </div>

                <div class="col-md-7 col-lg-6 mt-xs-10">
                    <div class="site-setting-menu">
                        <ul class="nav justify-content-center justify-content-md-end">
                            <li><a href="http://localhost:8080/dreamgame/Dream-admin/login.html">后台登录</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End PreHeader Area -->

    <!-- Start Header Middle Area -->
    <div class="header-middle-area">
        <div class="container">
            <div class="row">
                <!-- Logo Area Start -->
                <div class="col-4 col-md-2 col-xl-3 m-auto text-center text-lg-left">
                    <a href="index.html" class="logo-wrap d-block">
                        <img src="assets/img/logo.png" alt="Logo" class="img-fluid"/>
                    </a>
                </div>
                <!-- Logo Area End -->

            </div>
        </div>
    </div>
</header>
    <!-- End Header Middle Area -->

<!--== Start Page Breadcrumb ==-->
<div class="page-breadcrumb-wrap">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-breadcrumb">
                    <ul class="nav">
                        <li><a class="active">登录注册</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<!--== End Page Breadcrumb ==-->

<!--== Page Content Wrapper Start ==-->
<div id="page-content-wrapper">
    <div class="container">
        <div class="member-area-from-wrap">
            <div class="row">
                <!-- Login Content Start -->
                <div class="col-lg-5">
                    <div class="login-reg-form-wrap  pr-lg-50">
                        <h2>已经有账号了?</h2>

                        <form id="loginform">
                            <div class="single-input-item">
                                <input type="text" id="account_number1" name="account_number" placeholder="请输入帐号" required="required" />
                            </div>

                            <div class="single-input-item">
                                <input type="password" id="password1" name="password" placeholder="请输入密码"  required="required"/>
                            </div>
                            <div class="single-input-item">
                                <div class="login-reg-form-meta d-flex align-items-center justify-content-between">
                                    <div class="remember-meta">
                                        <div class="custom-control custom-checkbox">
                                            <input type="checkbox" class="custom-control-input" id="rememberMe">
                                            <label class="custom-control-label" for="rememberMe">记住我</label>
                                        </div>
                                    </div>

                                    <a href="#" class="forget-pwd">忘记密码?</a>
                                </div>
                            </div>

                            <div class="single-input-item">
                                <button id="loginbtn" type="button"  class="btn">登录</button>
                            </div>

                        </form>
                    </div>
                </div>

                <!-- Login Content End -->

                <!-- 用户注册开始 -->
                <div class="col-lg-7 mt-30 mt-lg-0">
                    <div class="login-reg-form-wrap">
                        <h2>用户注册</h2>
                        <form id="signform">
                            <div class="single-input-item">
                                <input type="text" name="user_name" id="user_name" placeholder="用户名" required="required" />
                            </div>

                            <div class="single-input-item">
                                <input type="text" name="account_number" id="account_number" placeholder="账号" required="required" />
                            </div>

                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="single-input-item">
                                        <input type="password" id="password" name="password" placeholder="密码" required="required" />
                                    </div>

                                </div>
                            </div>

                            <select name="sex" id="sex">
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>

                            <div class="single-input-item">
                                <input type="text" id="email" name="email" placeholder="邮箱" required="required" />
                            </div>

                            <!--                            <select name="userlevel" id="userlevel">-->
                            <!--                                <label for="userlevel" class="sr-only">等级</label>-->
                            <!--                                <option value="0">普通用户</option>-->
                            <!--                                <option value="1">管理员</option>-->
                            <!--                            </select>-->



                            <div class="single-input-item">
                                <button type="button" id="checkout" name="checkout" class="btn">立即注册</button>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- Register Content End -->
            </div>
        </div>
    </div>
</div>
<script src="js/jquery-2.1.0.js"></script>
<script type="text/javascript">

    //注册按钮点击事件
    $("#checkout").click(function (){

        $.ajax({
            url:"http://localhost:8080/dreamgame/user/add",

            async:"true",

            type:"post",

            contentType: "application/json",
            data: JSON.stringify(convertFormtoJson("signform")),

            success:(r)=>{
                //判断是否注册成功
                if(r.code ==1){
                    //若成功，跳转页面
                    alert("注册成功");
                    window.location.reload(true);
                }else {
                    //若失败，弹出错误提示
                    alert(r.msg);
                }

            },
            error:(r)=>{

                alert("注册失败");
            }
        })

    })

    //登录按钮点击事件
    $("#loginbtn").click(function (){

        $.ajax({
            url:"http://localhost:8080/dreamgame/user/login",

            async:"true",

            type:"post",

            contentType: "application/json",
            data: JSON.stringify(convertFormtoJson("loginform")),

            success:(r)=>{
                //判断是否登录成功
                if(r.code ==1){
                    //若成功，跳转页面
                    window.location.href ='index.html'
                }else {
                    //若失败，弹出错误提示
                    alert(r.msg);
                }

            }
        })

    })

    /**
     *
     * @param frm form表单的id
     * @returns {{}}
     */
    function convertFormtoJson(frm) {
        var obj = {};
        var arr = $("#"+frm).serializeArray();
        $.each(arr, function() {
            if (obj[this.name] !== undefined) {
                if (!obj[this.name].push) {
                    obj[this.name] = [obj[this.name]];
                }
                obj[this.name].push(this.value || '');
            } else {
                obj[this.name] = this.value || '';
            }
        });
        console.log(obj);
        return obj;
    }

</script>



<!--=======================Javascript============================-->
<!--=== Jquery Min Js ===-->
<!--<script src="assets/js/vendor/jquery-3.3.1.min.js"></script>-->
<!--=== Jquery Migrate Min Js ===-->
<script src="assets/js/vendor/jquery-migrate-1.4.1.min.js"></script>
<!--=== Popper Min Js ===-->
<script src="assets/js/vendor/popper.min.js"></script>
<!--=== Bootstrap Min Js ===-->
<script src="assets/js/vendor/bootstrap.min.js"></script>
<!--=== Ajax Mail Js ===-->
<script src="assets/js/ajax-mail.js"></script>
<!--=== Plugins Min Js ===-->
<script src="assets/js/plugins.js"></script>

<!--=== Active Js ===-->
<script src="assets/js/active.js"></script>





<!-- <script type="text/javascript">
$(function () {
	$("#checkout").click(function () {
	$.ajax({
	type:"post",
	url:"us.do?op=add",
	async:true,
	data:,
	success:function (data) {
				console.log("data: "+data)
			}
		});
	});
});
</script> -->
</body>
</html>